#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s1[112345];

int main()
{
	int a=2;
	s1[1]=2;
	for(int i=2;i<=30000;i++){
		s1[i]=s1[i-1]+a*i+i-1;
	}
	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		int s=0;
		while(n>=2){
			for(int i=1;i<=30000;i++){
				if(n>=s1[i]&&n<s1[i+1]){
					s++;
					n-=s1[i];
				}
			}
		}	
		cout<<s<<endl;
	}
	return 0;
}
